package com.joysuch.wwyt.risk.repository;


import com.joysuch.wwyt.risk.entity.RiskEvaluationTargetItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface RiskEvaluationTargetItemDao extends JpaRepository<RiskEvaluationTargetItem, Long> {

    int countByNameAndTypeId(String name, Long typeId);

    List<RiskEvaluationTargetItem> findByTypeId(Long typeId);

    @Query(value = " SELECT * FROM wwyt_risk_evaluation_target_item WHERE  NAME = ?1 AND type_id IN ?2 AND delete_flag = '0'", nativeQuery = true)
    List<RiskEvaluationTargetItem> findByNameAndTypeIds(String content, List<Long> typeIdList);

    @Query(value = " SELECT * FROM wwyt_risk_evaluation_target_item WHERE type_id IN ?1 AND score =?2 AND delete_flag = '0'", nativeQuery = true)
    List<RiskEvaluationTargetItem> findByTypeIdsAndScore(List<Long> idList, Double valueOf);
}
